package com.smarttiger.zero.admin.dto;

import com.smarttiger.zero.admin.entity.DictionaryModel;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;


public class DictionaryDto extends BaseDto{

    private String code;
    private String key;
    private String label;
    private String parentCode;


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getParentCode() {
        return parentCode;
    }

    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }

//    private List<DictionaryDto> dictionaryModels;
//
//    public List<DictionaryDto> getDictionaryModels() {
//        return dictionaryModels;
//    }
//
//    public void setDictionaryModels(List<DictionaryDto> dictionaryModels) {
//        this.dictionaryModels = dictionaryModels;
//    }

    static public DictionaryDto tranlate(DictionaryModel f){
        DictionaryDto t = new DictionaryDto();
        BeanUtils.copyProperties(f,t,"dictionaryModels");

//        List<DictionaryDto> rall = new ArrayList<>();
//        f.getDictionaryModels().forEach(e->{
//            DictionaryDto dto = new DictionaryDto();
//            BeanUtils.copyProperties(e,dto);
//            rall.add(dto);
//        });
//        t.setDictionaryModels(rall);

        return t;
    }

    static public List<DictionaryDto> tranlateList(List<DictionaryModel> f){
        List<DictionaryDto> t = new ArrayList<>();
        f.forEach(e->{
            DictionaryDto dto = DictionaryDto.tranlate(e);
            t.add(dto);
        });
        return t;
    }

}
